package com.crm.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.crm.dao.CustomerDao;
import com.crm.dao.LinkmanDao;
import com.crm.dao.impl.CustomerDaoImpl;
import com.crm.dao.impl.LinkmanDaoImpl;
import com.crm.pojo.Linkman;
import com.crm.pojo.PageInfo;
import com.crm.service.LinkmanService;

public class LinkmanServiceImpl implements LinkmanService {
	LinkmanDao linkmanDao = new LinkmanDaoImpl();
	CustomerDao customerDao = new CustomerDaoImpl();
	@Override
	public List<Map> queryCustomer() {
		return customerDao.queryCustomer();
	}
	@Override
	public boolean insertLinkman(Linkman linkman) {
		boolean flag = false;
		int n = linkmanDao.insertLinkman(linkman);
		if(n==1) {
			flag = true;
		}
		return flag;
	}
	@Override
	public PageInfo queryLinkman(String lkmName, Integer pageSize, Integer pageNumber) {
		return linkmanDao.queryLinkman(lkmName,pageSize,pageNumber);
	}
	@Override
	public boolean deleteLinkman(Integer lkmId) {
		boolean flag = false;
		int n = linkmanDao.deleteLinkman(lkmId);
		if(n==1) {
			flag = true;
		}
		return flag;
	}
	@Override
	public Map queryLinkman(Integer lkmId) {
		List<Map> linkmans = linkmanDao.queryLinkman(lkmId);
		Map linkman = new HashMap();
		for(Map l:linkmans) {
			linkman = l;
		}
		return linkman;
	}
	@Override
	public boolean updateLinkman(Linkman linkman) {
		boolean flag = false;
		int n = linkmanDao.updateLinkman(linkman);
		if(n==1) {
			flag = true;
		}
		return flag;
	}

}
